package jwlee.testproxy.aop;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;

/**
 * aop方式ProxyFactoryBean代理
 * @author warison
 *
 * Oct 20, 2009
 */
public class LogAround implements MethodInterceptor {
	private Logger logger = Logger.getLogger(this.getClass().getName()); 
	@Override
	public Object invoke(MethodInvocation mi) throws Throwable {
		// TODO Auto-generated method stub
		logger.log(Level.INFO, mi.getArguments()[0] + " 审核数据开始....");
			try { 
				
	          Object result = mi.proceed(); 

	          //返回值即是被调用的方法的返回值

	          return result; 

	        } finally { 

	          logger.log(Level.INFO, mi.getArguments()[0] + " 审核数据结束....");

	        }     

	}

    
}

